<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateStatOpeninstallChannelTable extends Migration
{
    protected $connection = 'stat';
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('stat_daily_openinstall_channel', function (Blueprint $table) {
            $table->increments('id');
            $table->date('dt')->comment('统计日期');
            $table->integer('install')->default(0)->comment('安装数');
            $table->integer('register')->default(0)->comment('注册数');
            $table->integer('survive_d1')->default(0)->comment('1日留存');
            $table->integer('survive_d7')->default(0)->comment('7日留存');
            $table->integer('survive_d30')->default(0)->comment('30日留存');
            $table->char('channel', 10)->default('')->comment('渠道');
            $table->timestamps();
            $table->tinyInteger('flag')->default(1)->comment('记录状态');
            $table->index('dt', 'dt');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('stat_daily_openinstall_channel', function (Blueprint $table) {
            //
        });
    }
}
